/**
 *  File: common.h
 *
 *  Copyright (C) 2008 Du XiaoGang <dugang@188.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 */

#ifndef _COMMON_H
#define _COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
#include <fcntl.h>
#include <ctype.h>
#include <signal.h>
#include <time.h>
#include <zlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <asm/param.h>

#define SOFTWARE        "TestHttpd"
#define VERSION         "0.1.0"
#define STAT_COUNT_MAX  800
#define STAT_INTERVAL   5
#define STATPAGE_MAX    (512 * 1024)

#define ERR(string) \
        do { \
            fprintf(stderr, \
                    "Unexpected error occurred(%s:%d), errno = %d.\n" \
                    "  AUX-Message: %s.\n", \
                    __FILE__, __LINE__, errno, string); \
        } while (0)

struct entity_t {
    union {
        int status;
        const char *name;
    } u;
    char *header;
    int header_dyn;
    size_t header_length;
    char *body;
    int body_dyn;
    size_t body_length;
};

struct statistic_t {
    size_t accepted, completed, max_conns;
    size_t received, sent;
    int cpu_usedp, cpu_httpdp;
    int mem_usedp, mem_cachedp, mem_httpdp;
};

#endif /* _COMMON_H */
